<?php
define("LOGINSTATUS_OFF", 1);
define("LOGINSTATUS_ON", 2);

Class LoginManager
{
	static function get_login_user()
	{
		session_start();
		$user = $_SESSION["login_user"];
		if (empty($user)) 
		{
			return false;
		}
		else
		{
			return $user;
		}
	}
	
	static function get_login_type()
	{
		if (empty($_SESSION["login_user"]))	return false;
		return $_SESSION['login_type'];
	}
	
	static function set_login($user, $login_type = USERTYPE_OWN)
	{
		session_start();
		$_SESSION['login_time'] = date("Y-m-d H:i:s");
		$_SESSION['login_user'] = $user;
		$_SESSION['login_type'] = $login_type;
	}
	
	static function logout()
	{
		session_start();
		$_SESSION[$user."_login"] = null;
		$_SESSION["login_user"] = null;
		unset($_SESSION["login_user"]);
		unset($_SESSION[$user."_login"]);
		session_destroy();
		
		return true;
	}
}

?>